package com.cqc.flycotablayout01.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.ContentFrameLayout;

import com.cqc.flycotablayout01.R;
import com.cqc.flycotablayout01.fragment.Frag1;
import com.cqc.flycotablayout01.fragment.Frag2;
import com.cqc.flycotablayout01.fragment.Frag3;
import com.cqc.flycotablayout01.fragment.Frag4;
import com.cqc.flycotablayout01.module.TabModule;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by ${cqc} on 2017/9/12.
 */

public class CommonTabLayoutActivity extends AppCompatActivity {

    @BindView(R.id.tabLayout)
    CommonTabLayout tabLayout;
    @BindView(R.id.fl)
    ContentFrameLayout fl;
    @BindView(R.id.tabLayout2)
    CommonTabLayout tabLayout2;
    @BindView(R.id.tabLayout3)
    CommonTabLayout tabLayout3;

    private String[] titles = {"语文", "数学", "英语", "物理"};
    private int[] mIconUnselectIds = {R.mipmap.tab_home_unselect, R.mipmap.tab_speech_unselect, R.mipmap.tab_contact_unselect, R.mipmap.tab_more_unselect};
    private int[] mIconSelectIds = {R.mipmap.tab_home_select, R.mipmap.tab_speech_select, R.mipmap.tab_contact_select, R.mipmap.tab_more_select};

    private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
    private ArrayList<Fragment> frags = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_common_tab_layout);
        ButterKnife.bind(this);

        for (int i = 0; i < titles.length; i++) {
            mTabEntities.add(new TabModule(titles[i], mIconSelectIds[i], mIconUnselectIds[i]));
        }
        tabLayout.setTabData(mTabEntities);


        frags.add(new Frag1());
        frags.add(new Frag2());
        frags.add(new Frag3());
        frags.add(new Frag4());
        tabLayout2.setTabData(mTabEntities, this, R.id.fl, frags);
//        tabLayout3.setTabData(mTabEntities, this, R.id.fl, frags);
    }
}
